package groupware;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import com.google.appengine.api.users.User;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Tree<T> {
    private Node<T> root;
    public Tree() {
        super();
    }
    public Node<T> getRoot() {
        return this.root;
    }
    public void setRoot(Node<T> root) {
        this.root = root;
    }
    public List<Node<T>> toList() {
        List<Node<T>> list = new ArrayList<Node<T>>();
        walk(root, list);
        return list;
    }
    public String toString() {
        return toList().toString();
    }
    private void walk(Node<T> element, List<Node<T>> list) {
        list.add(element);
        for (Node<T> data : element.getChildren()) {
            walk(data, list);
        }
    }	 
}
